//
//  ScoreObtainAndConsumeViewCell.m
//  NiuBanJinGold
//
//  Created by Billy on 15/10/16.
//  Copyright © 2015年 zzjr. All rights reserved.
//

#import "ScoreObtainAndConsumeViewCell.h"

@interface ScoreObtainAndConsumeViewCell ()

@property (nonatomic, strong) UILabel *label_reason;
@property (nonatomic, strong) UILabel *label_time;
@property (nonatomic, strong) UILabel *label_score;

@end


@implementation ScoreObtainAndConsumeViewCell

#pragma mark - subviews creation

- (void) subViewsCreation {
    
    [self setBackgroundColor:[UIColor whiteColor]];
    // cell 构成: 1. 左view [a. 上label b. 下label ]   2. 右view
    
    self.label_reason = [UsefulUtil labelCreationWithFrame:CGRectMake(MULTIPLYWIDTH(30.0/2), MULTIPLYHEIGHT(16.0/2), MULTIPLYWIDTH(200.0/2), MULTIPLYHEIGHT(42.0/2)) textColor:[UsefulUtil colorWithHexString:@"#434343"] fontName:[UIFont systemFontOfSize:15.0] text:@"首次登录"];
    
    [self.contentView addSubview:self.label_reason];
    
    self.label_time = [UsefulUtil labelCreationWithFrame:CGRectMake(MULTIPLYWIDTH(30.0/2), CGRectGetMaxY(self.label_reason.frame) +MULTIPLYHEIGHT(10.0/2), MULTIPLYWIDTH(200.0/2), MULTIPLYHEIGHT(22.0/2)) textColor:[UsefulUtil colorWithHexString:@"#989898"] fontName:[UIFont systemFontOfSize:11.0] text:@"2015-09-24 15:45:23"];

    [self.label_time  sizeToFit]; //调整间距
    
    [self.contentView addSubview:self.label_time];
    
    self.label_score = [UsefulUtil labelCreationWithFrame:CGRectMake(SCREEN_WIDTH/2, MULTIPLYHEIGHT(30.0/2), SCREEN_WIDTH/2 - MULTIPLYWIDTH(30.0/2), MULTIPLYHEIGHT(40.0/2)) textColor:[UsefulUtil colorWithHexString:@"#989898"] fontName:[UIFont systemFontOfSize:17.0] text:@"积分 + 500"];
    [self.label_score setTextAlignment:NSTextAlignmentRight];
    
    [self.label_score setTextColor:[UsefulUtil colorWithHexString:@"#fd4747"]];
    
    [self.contentView addSubview:self.label_score];
    
    UIView *view_sep = [[UIView alloc] initWithFrame:CGRectMake(MULTIPLYWIDTH(30.0/2), MULTIPLYHEIGHT(49.5), SCREEN_WIDTH, MULTIPLYHEIGHT(1.0/2))];
    
    
    [view_sep setBackgroundColor:[UsefulUtil colorWithHexString:@"#c8c7cc"]];
    
    [self.contentView addSubview:view_sep];
}

- (void)layoutSubviews {
    
    [self.label_reason setText:self.scoreAndExchange.scoreAndExchange_reason];
    [self.label_time setText:self.scoreAndExchange.scoreAndExchange_time];
    
    if ([self.type isEqualToString:@"exchangeHistory"]) {
        
        NSString *type = @" + ";
        
        if ([self.scoreAndExchange.scoreAndExchange_isConsume boolValue]) { //消费
            
            type = @"";
        }
        
        [self.label_score setText:[NSString stringWithFormat:@"积分%@%@",type,self.scoreAndExchange.scoreAndExchange_value]];
        
    }else if ([self.type isEqualToString:@"scoreHistory"])  { //防止还有第三种类型，所以不用else
        
                [self.label_score setText:[NSString stringWithFormat:@"积分%@",self.scoreAndExchange.scoreAndExchange_Scorevalue]];
    }
}



- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
